package com.x.client.activity

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.gg.baselibrary.BaseActivity
import com.gg.utils.StatusUtils
import com.gg.widget.navigationbar.DefaultNavigationBar
import com.jakewharton.rxbinding2.widget.RxTextView
import com.x.client.R
import com.x.client.utils.RouterClass
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.activity_feedback.*
import java.util.concurrent.TimeUnit

/**
 * Creator : GG
 * Date    : 2018/6/7
 * Mail    : gg.jin.yu@gmai.com
 * Explain :
 */
@Route(path = RouterClass.feedback)
class FeedbackActivity : BaseActivity() {

    private var feedbackDetails = ""

    private var phoneNum = ""

    override fun getLayoutRes(): Int = R.layout.activity_feedback

    override fun initTitle() {
        super.initTitle()
        StatusUtils.setStatusTextColor(true, this)
        StatusUtils.setStatusBar(this, false, false)
        DefaultNavigationBar.Builder(this)
                .setMiddleText(getString(R.string.feedback))
                .setStatusBarHeight(StatusUtils.getStatusBarHeight(this))
                .setLeftIcon(R.drawable.ic_back_black)
                .setLeftClickListener(View.OnClickListener { finish() })
                .create()
    }


    override fun initView() {

        RxTextView.textChanges(editFeedback)
                .debounce(500, TimeUnit.MICROSECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .compose(this.bindToLifecycle())
                .subscribe {
                    feedbackDetails = it.toString()
                    lengthPrompt.text = "${it.length}/50"
                }

        RxTextView.textChanges(editPhone)
                .skipInitialValue()
                .debounce(500, TimeUnit.MICROSECONDS)
                .compose(this.bindToLifecycle())
                .subscribe {
                    phoneNum = it.toString()
                }


    }

    override fun initData() {
    }
}